package handlers

import (
	"errors"

	rpc "../lib/jsonrpc2"
)

var (
	// ErrMissingParams 丢失参数
	ErrMissingParams = errors.New("Missing Params")

	// ErrInvalidCaptcha 无效的图形验证码
	ErrInvalidCaptcha = errors.New("Invalid Captcha")

	// ErrInvalidMobile 无效的手机号
	ErrInvalidMobile = errors.New("Invalid Mobile")

	// ErrInvalidToken 无效的token
	ErrInvalidToken = errors.New("Invalid Token")

	// ErrMobileNotMatches 手机号不匹配
	ErrMobileNotMatches = errors.New("Mobile Not Matches")

	// ErrCodeNotMatches 验证码不匹配
	ErrCodeNotMatches = errors.New("Code Not Matches")

	// ErrMobileExisted 手机号已存在
	ErrMobileExisted = errors.New("Mobile Existed")

	// ErrWrongUserOrPass 用户名或密码错误
	ErrWrongUserOrPass = errors.New("Invalid User or Pass")
)

func toRPCError(err error) *rpc.RPCError {
	return &rpc.RPCError{Code: -32000, Message: err.Error()}
}

func newRPCError(err error) *rpc.RPCError {
	return &rpc.RPCError{Code: -32000, Message: err.Error()}
}
